package org.corey.wyp.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.rpc.IResponder;
	
	import org.corey.wyp.business.PropertyManagerDelegate;
	import org.corey.wyp.event.SettingTemplateGetterEvent;
	import org.corey.wyp.model.ProperityModelLocator;
	import org.corey.wyp.vo.SettingTemplateType;
	
	public class SettingTemplateGetterCommand implements ICommand,IResponder
	{
		public var settingType:String;
		
		public function SettingTemplateGetterCommand()
		{
		}
		
		public function execute(event:CairngormEvent):void{
			var getterEvent:SettingTemplateGetterEvent=SettingTemplateGetterEvent(event);
			settingType=getterEvent.settingType;
			var pm:PropertyManagerDelegate=new PropertyManagerDelegate(this);
			pm.getSettingTemplate(settingType);
		}
		
		public function result(event:Object):void{
				if(SettingTemplateType.MONTH==settingType){
					ProperityModelLocator.getInstance().application.monthSettingTemplates=event.result as ArrayCollection;
				}else if(SettingTemplateType.DAY==settingType){
					ProperityModelLocator.getInstance().application.daySettingTemplates=event.result as ArrayCollection;
				}
		}
		
		public function fault(info:Object):void{
			Alert.show("增加信息失败:"+info);
		}


	}
}